package com.ssyc.gsk_master.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.ssyc.common.glide.ImageUtil;
import com.ssyc.gsk_master.R;
import com.ssyc.gsk_master.bean.PayInfo;

import java.util.List;

/**
 * 缴费明细的适配器
 * Created by Administrator on 2018/7/18 0018.
 */

public class PayRvAdapter extends BaseQuickAdapter<PayInfo.ListBean, BaseViewHolder> {
    private Context context;

    public PayRvAdapter(Context context, int layoutResId, @Nullable List<PayInfo.ListBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, PayInfo.ListBean item) {

        //最外层布局
        RelativeLayout rlOut = helper.getView(R.id.rl_out);

        //头像
        RoundedImageView ivHead = helper.getView(R.id.iv_head);
        ImageUtil.displayImage(context, ivHead, item.getIcon(), R.drawable.defaultimage);

        //名称
        TextView tvName = helper.getView(R.id.tv_name);
        tvName.setText(item.getName());

        //缴费状态
        TextView tv_state = helper.getView(R.id.tv_state);
        if ("已缴".equals(item.getPayment())) {
            tv_state.setText("已缴");
            tv_state.setBackgroundResource(R.drawable.master_tv_payyes);
            tv_state.setTextColor(context.getResources().getColor(R.color.coffee));
            rlOut.setBackgroundResource(R.drawable.master_pay_state_yes);
        } else {
            rlOut.setBackgroundResource(R.drawable.master_pay_state_no);
            tv_state.setBackgroundResource(R.drawable.master_tv_payno);
            tv_state.setTextColor(context.getResources().getColor(R.color.white));
            if ("未缴".equals(item.getPayment())) {
                tv_state.setText("未缴");
            } else {
                tv_state.setText(item.getPayment());
            }
        }

    }
}
